package data

import "061/Sgame/server/game/model"

// RoleRes 角色资源
type RoleRes struct {
	Id     int `gorm:"column:id;primaryKey"`
	RId    int `gorm:"column:rid"`
	Wood   int `gorm:"column:wood;comment:木"`
	Iron   int `gorm:"column:iron;comment:铁"`
	Stone  int `gorm:"column:stone;comment:石头"`
	Grain  int `gorm:"column:grain;comment:粮食"`
	Gold   int `gorm:"column:gold;comment:金币"`
	Decree int `gorm:"column:decree;comment:令牌"` //令牌
}

func (r *RoleRes) TableName() string {
	return "role_res"
}

// Yield 产量
type Yield struct {
	Wood  int
	Iron  int
	Stone int
	Grain int
	Gold  int
}

func (r *RoleRes) ToModel() interface{} {
	p := model.RoleRes{}
	p.Gold = r.Gold
	p.Grain = r.Grain
	p.Stone = r.Stone
	p.Iron = r.Iron
	p.Wood = r.Wood
	p.Decree = r.Decree

	yield := GetYield(r.RId)
	p.GoldYield = yield.Gold
	p.GrainYield = yield.Grain
	p.StoneYield = yield.Stone
	p.IronYield = yield.Iron
	p.WoodYield = yield.Wood
	p.DepotCapacity = 10000
	return p
}
